import {instance} from "@/api/baseReq.js";

export const getData = async (map_path = null) => {
    const api = 'http://127.0.0.1:8099/cal/getGwProb';
    // const api = 'https://svom-gwacn.cn/tools/cal/getGwProb';
    const res = await instance.get(api, {
        params: {map_path: map_path}
    })
    // console.log(res);
    const rst = res.data;
    if (rst.code === 0) {
        return rst.data;
    } else {
        await Promise.reject(rst.msg);
    }
}


export const getRect = async (cRa, cDec, fovX, fovY, k = 1) => {
    const api = 'http://127.0.0.1:8099/cal/getRectPoints';
    // const api = 'https://svom-gwacn.cn/tools/cal/getRectPoints';
    const res = await instance.get(api, {
        params: {
            center_ra: cRa,
            center_dec: cDec,
            fov_x: fovX,
            fov_y: fovY,
            k: k
        }
    })
    // console.log(res);
    const rst = res.data;
    if (rst.code === 0) {
        return rst.data;
    } else {
        await Promise.reject(rst.msg);
    }
}